#include <iostream>
#include "vector"
#include "map"

using namespace std;

/*
 * 10个员工，不同部门  员工信息包括  姓名、工资、部门(策划、美术、研发)
 * 随机分配部门与工资    通过multimap进行信息插入(key 部门编号   value   员工)
 * 分部门显示员工信息
 */

class Person{
public:
    string p_name;
    int p_salary;
    int p_dept;
    Person(string name, int salary, int dept){
        this->p_name = name;
        this->p_salary = salary;
        this->p_dept = dept;
    }
};

void test01(){
    srand((unsigned) time(nullptr));
    vector<Person> v;
    string nameSeed = "ABCDEFGHIJ";
    for (int i = 0; i < 10; ++i) {
        string name = "员工";
        name += nameSeed[i];
        int salary = rand() % 10000 + 10000;
        int dept;
        if(i<3){
            dept = 3;
        } else if (i>=3 && i<6){
            dept = 2;
        } else{
            dept = 1;
        }
        Person p(name, salary, dept);
        v.push_back(p);
    }
    multimap<int, Person> m;
    for (vector<Person>::iterator it= v.begin(); it!= v.end() ; ++it) {
        m.insert(pair<int, Person>(it->p_dept, *it));
    }
    for (multimap<int, Person>::iterator it= m.begin(); it!= m.end(); ++it) {
        cout << "name= " << it->second.p_name << ", salary= " << it->second.p_salary << ", dept= " << it->second.p_dept << endl;
    }
}

int main() {

    test01();

    return 0;
}
